package com.toman.Welcome;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.AlphaAnimation;

import com.toman.Login.LoginActivity;
import com.toman.R;
import com.toman.Util.ViewUtil;
import com.toman.widget.MyImageView;

import java.util.Timer;
import java.util.TimerTask;

public class Welcome extends AppCompatActivity {

    MyImageView mWelcomeImg;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //设置为无标题栏
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        //设置为全屏模式
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_welcome);
        initView();
    }


    /*
        初始化控件
     */
    public void initView() {
        mWelcomeImg = (MyImageView) findViewById(R.id.mWelcomeImg);
        if (ViewUtil.isAllScreenDevice(this)){
            mWelcomeImg.setImageDrawable(getResources().getDrawable(R.mipmap.start_new));
        }
        //背景透明度变化3秒内从0.3变到1.0
        AlphaAnimation aa = new AlphaAnimation(0.1f, 1.0f);
        aa.setDuration(2000);
        mWelcomeImg.startAnimation(aa);


        //创建Timer对象
        Timer timer = new Timer();
        //创建TimerTask对象
        TimerTask timerTask = new TimerTask() {
            @Override
            public void run() {
                Intent intent = new Intent(Welcome.this, LoginActivity.class);
                startActivity(intent);
                finish();
            }
        };
        timer.schedule(timerTask, 2000);
    }
    public void onDestroy() {
        // TODO Auto-generated method stub


        super.onDestroy();}


}
